package com.yidu.ruifeng_logistics.service.impl;

import com.yidu.ruifeng_logistics.entity.LogisticsCargo;
import com.yidu.ruifeng_logistics.dao.LogisticsCargoDao;
import com.yidu.ruifeng_logistics.service.LogisticsCargoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (LogisticsCargo)表服务实现类
 *
 * @author makejava
 * @since 2021-03-09 14:24:37
 */
@Service("logisticsCargoService")
public class LogisticsCargoServiceImpl implements LogisticsCargoService {
    @Resource
    private LogisticsCargoDao logisticsCargoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param cargoId 主键
     * @return 实例对象
     */
    @Override
    public LogisticsCargo queryById(Integer cargoId) {
        return this.logisticsCargoDao.queryById(cargoId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<LogisticsCargo> queryAllByLimit(int offset, int limit) {
        return this.logisticsCargoDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param logisticsCargo 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsCargo insert(LogisticsCargo logisticsCargo) {
        this.logisticsCargoDao.insert(logisticsCargo);
        return logisticsCargo;
    }

    /**
     * 修改数据
     *
     * @param logisticsCargo 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsCargo update(LogisticsCargo logisticsCargo) {
        this.logisticsCargoDao.update(logisticsCargo);
        return this.queryById(logisticsCargo.getCargoId());
    }

    /**
     * 通过主键删除数据
     *
     * @param cargoId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer cargoId) {
        return this.logisticsCargoDao.deleteById(cargoId) > 0;
    }

    @Override
    public List<LogisticsCargo> queryAll(LogisticsCargo logisticsCargo) {
        return this.logisticsCargoDao.queryAll(logisticsCargo);
    }

}
